package main

import (
	"fmt"
)

/*
channel 读写案例 1

在for循环中,由于select 为随机选取
		0
read
write

*/

func main() {

	ch := make(chan int, 2)

	for i := 0; i < 10; i++{
		//fmt.Println("循环次数：",i)
		select {
			case x := <-ch:
				fmt.Println("读取数据为:",x)
				//fmt.Println(ch)

			case ch <- i:
				//fmt.Println("channel写入:",i)
				//fmt.Println(ch)
		}
	}

	//for i := 0; i < 10; i++{
	//	fmt.Println(i)
	//	fmt.Println(ch)
	//}



}

